package net.mingsoft.base.entity;

import java.io.*;
import org.springframework.format.annotation.*;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.*;
import net.mingsoft.base.constant.e.*;
import org.apache.commons.lang3.*;
import cn.hutool.json.*;
import java.util.*;

public abstract class BaseEntity implements Serializable
{
    protected String createBy;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected Date createDate;
    protected Integer del;
    protected String id;
    @TableField(exist = false)
    protected String remarks;
    protected String updateBy;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected Date updateDate;
    @JsonIgnore
    @TableField(exist = false)
    protected String sqlWhere;
    @JsonIgnore
    @TableField(exist = false)
    protected String sqlDataScope;
    @JsonIgnore
    @TableField(exist = false)
    protected String orderBy;
    @TableField(exist = false)
    protected String order;
    
    public BaseEntity() {
        this.del = 0;
    }
    
    public String getCreateBy() {
        return this.createBy;
    }
    
    public void setCreateBy(final String createBy) {
        this.createBy = createBy;
    }
    
    public Date getCreateDate() {
        return this.createDate;
    }
    
    public void setCreateDate(final Date createDate) {
        this.createDate = createDate;
    }
    
    public Integer getDel() {
        return this.del;
    }
    
    @JsonIgnore
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public void setDel(final DeleteEnum del) {
        this.del = del.toInt();
    }
    
    public void setDel(final Integer del) {
        this.del = del;
    }
    
    public String getId() {
        if (StringUtils.isEmpty((CharSequence)this.id) || this.id.equals("0")) {
            return null;
        }
        return this.id;
    }
    
    public Integer getIntegerId() {
        if (StringUtils.isEmpty((CharSequence)this.getId())) {
            return null;
        }
        return Integer.parseInt(this.getId());
    }
    
    public int getIntId() {
        if (StringUtils.isEmpty((CharSequence)this.getId())) {
            return 0;
        }
        return Integer.parseInt(this.getId());
    }
    
    public void setId(String id) {
        if (StringUtils.isEmpty((CharSequence)id) || id.equals("0")) {
            id = null;
        }
        this.id = id;
    }
    
    @JsonIgnore
    public void setIntegerId(final Integer id) {
        this.id = String.valueOf(id);
    }
    
    @JsonIgnore
    public void setIntId(final int id) {
        this.id = String.valueOf(id);
    }
    
    public String getRemarks() {
        return this.remarks;
    }
    
    public void setRemarks(final String remarks) {
        this.remarks = remarks;
    }
    
    public String getUpdateBy() {
        return this.updateBy;
    }
    
    public void setUpdateBy(final String updateBy) {
        this.updateBy = updateBy;
    }
    
    public Date getUpdateDate() {
        return this.updateDate;
    }
    
    public void setUpdateDate(final Date updateDate) {
        this.updateDate = updateDate;
    }
    
    @JsonIgnore
    public String getSqlWhere() {
        return this.sqlWhere;
    }
    
    @JsonIgnore
    public List getSqlWhereList() {
        if (StringUtils.isNotBlank((CharSequence)this.sqlWhere)) {
            try {
                return JSONUtil.toList(this.sqlWhere, (Class)Map.class);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
        return Collections.EMPTY_LIST;
    }
    
    public void setSqlWhere(final String sqlWhere) {
        this.sqlWhere = sqlWhere;
    }
    
    public String getOrderBy() {
        return this.orderBy;
    }
    
    public void setOrderBy(String orderBy) {
        if (orderBy != null) {
            orderBy = orderBy.replaceAll(" ", "");
        }
        this.orderBy = orderBy;
    }
    
    public String getSqlDataScope() {
        return this.sqlDataScope;
    }
    
    public void setSqlDataScope(final String sqlDataScope) {
        this.sqlDataScope = sqlDataScope;
    }
    
    public String getOrder() {
        return this.order;
    }
    
    public void setOrder(final String order) {
        this.order = order;
    }
}
